//
//  CYYNetWorkManager+SearchPartySecrectCode.m
//  LetsParty
//
//  Created by rimi on 15/9/18.
//  Copyright (c) 2015年 LetsPartyTeam. All rights reserved.
//

#import "CYYNetWorkManager+SearchPartySecrectCode.h"

@implementation CYYNetWorkManager (SearchPartySecrectCode)

/**< 根据暗号获得活动的ObjectId */
+ (void)getPartyObjectIdBySearchPartySecrectCode:(NSString *)partySecrectCode
                                          sucess:(SucessSearchPartySecrectCode)sucessGet
                                            fail:(Fail)fail{
    //建立查询类
    BmobQuery * bQuery = [[BmobQuery alloc]initWithClassName:@"Parties"];
    //查询约束1
    [bQuery whereKey:@"partySecretCode" equalTo:partySecrectCode];
    
    [bQuery findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) {
        if (error) {
            fail(error);
        }else{
            if (array.count != 0) {
                sucessGet(array[0]);
            }else{
                NSError * twoError = [[NSError alloc]initWithDomain:@"查无此活动" code:203918 userInfo:nil];
                fail(twoError);
            }
        }
    }];
}

@end
